﻿@using KRM.Core

@model KRM.Core.vKRMRSViewDisputeDetail
@{
    ViewBag.Title = "ViewRdm";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
    var db = new KRMEntities();

    var brief = db.vWebBriefOrderItemDetails.FirstOrDefault(a => a.OrderItemID == Model.OrderItemID);
    tblKRMRSDispute dispute = ViewBag.Dispute;
    var orderItem = db.tblOrderItems.Find(Model.OrderItemID);
    ViewBag.SignatureID = new SelectList(db.tblKRMRSDisputeSignatures.OrderBy(a => a.Signature), "SignatureID", "Signature", dispute.SignatureID);
    ViewBag.PackagingID = new SelectList(db.tblKRMRSDisputePackagings.OrderBy(a => a.Packaging), "PackagingID", "Packaging", dispute.PackagingID);
    var questionnaire = db.tblRDMQuestionnaires.Find(dispute.QuestionnaireID);
    var urlQuestion = questionnaire != null ? "/rdm/" + (questionnaire.IsFAC51CheckList == true ? "viewquestionnaireform" : "viewquestionnairenonfac") + "?qid=" + dispute.QuestionnaireID + "&disputeid=" + Model.DisputeID + "" : "javascript:;";
    var read = dispute.ActionID > 0 ? "disabled=disabled" : "";
    var disabled = dispute.ActionID > 0 ? "disabled" : "";
}
<div id="addPhoto" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form action="/rdm/addphoto" method="POST" enctype="multipart/form-data" class="margin0" id="fr-AddPhoto">
        <input type="hidden" name="DisputeID" value="@dispute.DisputeID"/>
        <input type="hidden" name="action" value="ViewRdm" />

        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h5 id="myModalLabel">Add image</h5>
        </div>
        <div class="modal-body">
            <div class="row-fluid">
                <div class="span3">Image</div>
                <div class="span9">
                    <input type="file" name="image" required="required" accept="image/*" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Description</div>
                <div class="span9">
                    <textarea name="Description" class="input-block-level"></textarea>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <input type="submit" class="btn btn-primary" value="Upload">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
    </form>
</div>
<div id="addDocument" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form action="/rdm/adddocument" method="POST" id="fr-AddDocument" enctype="multipart/form-data" class="margin0">
        <input type="hidden" name="DisputeID" value="@dispute.DisputeID"/>
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h5>Add document</h5>
        </div>
        <div class="modal-body">
            <div class="row-fluid">
                <div class="span3">Image</div>
                <div class="span9">
                    <input type="file" name="file" required="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Name</div>
                <div class="span9">
                    <input type="text" name="Name" class="input-block-level" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Description</div>
                <div class="span9">
                    <textarea name="Description" class="input-block-level"></textarea>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <input type="submit" class="btn btn-primary" value="Upload">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div>
    </form>
</div>
@Html.Partial("Partial/Rdm/_EditPhoto")
@Html.Partial("Partial/Rdm/_EditDocument")
<div style="padding: 10px">
    @Html.Partial("Partial/_MessageResult")
    <input type="hidden" id="OrderItemID" value="@Model.OrderItemID"/>
    <div class="row-fluid">
        <div class="span3">
            <div class="span3">OrderRef</div>
            <div class="span9">
                <input type="text" class="input-block-level" value="@brief.OrderRef" disabled="disabled" />
            </div>
        </div>
        <div class="span5">
            <div class="span3">OrderItems</div>
            <div class="span9">
                <input type="text" class="input-block-level" value="@Model.Order_Items" disabled="disabled" />
                @if (orderItem.Order.OrderItems.Any(p => p.ProductID == tblCompanyVariable.AssemblyProductID))
                {
                    <span style="color: red; font-weight: bold; font-size: 14px">NOTE: ORDER HAS ASSEMBLE SERVICE</span>
                }
            </div>
        </div>
        <div class="span4">
            <div class="span4">Despatch Date</div>
            <div class="span8">
                <input type="text" class="input-block-level" value="@brief.DespatchDate" disabled="disabled" />
            </div>
        </div>
    </div>
    <form action="/rdm/savedispute" method="POST" id="frsavedispute" class="validaterdm">
        <input type="hidden" name="DisputeID" value="@dispute.DisputeID" id="hfDisputeid"/>
        <input type="hidden" name="DisputeStatusID" id="hfDisputeStatusID" value="4" />
        <div class="row-fluid">
            <fieldset class="span6">
                <legend>RDM</legend>
                <div class="row-fluid">
                    <div class="span2">RDM Reason</div>
                    <div class="span4">
                        @Html.DropDownList("ReasonID", null, new { @class = "input-block-level", required = "required", disabled })
                    </div>
                    <div class="span2">Reason Detail</div>
                    <div class="span4">
                        @Html.DropDownList("ReasonDetailID", null, new { @class = "input-block-level", required = "required", disabled })
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Liability</div>
                    <div class="span4">
                        @Html.DropDownList("LiabilityID", null, new { @class = "input-block-level", disabled })
                    </div>
                    <div class="span2">Preferred Resolution</div>
                    <div class="span4">
                        @Html.DropDownList("ResolutionID", null, "Please Select a Resolution", new { @class = "input-block-level", onchange = "resolutionchange(this.value)", required = "required", disabled })
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Crime Reference Number</div>
                    <div class="span10">
                        <input type="number" name="CrimeReferenceNumber" class="input-block-level" value="@dispute.CrimeReferenceNumber" @read/></div>
                </div>
                <div class="row-fluid">
                    <div class="span2">RDM Items</div>
                    <div class="span8">
                        <textarea class="input-block-level" rows="2" name="DisputeItems" id="DisputeItems" @(new List<int>{1,2,3,4,11}.Contains(dispute.ResolutionID??0)? "required=required" : "")  @read>@(dispute.ResolutionID > 0 ? dispute.DisputeItems : "")
                        </textarea>
                        <input type="hidden" id="hfDisputeItems" value="@(dispute.DisputeItems + Environment.NewLine + orderItem.ProductSubOptions)"/>
                    </div>
                    <div class="span2">
                        <input type="checkbox" style="float: left; margin-right: 7px;" name="IsFullDisputeItems" value="True" @read @(dispute.IsFullDisputeItems == true ? "checked=checked" : "")
                            id="IsFullDisputeItems" />
                        Full Item
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Replacement Items</div>
                    <div class="span8">
                        <textarea class="input-block-level" rows="2" name="DisputeReplacementItems" id="DisputeReplacementItems" @(new List<int>{1,2,5}.Contains(dispute.ResolutionID??0)? "required=required" : "") @read>@(dispute.ResolutionID > 0 ? dispute.DisputeReplacementItems : "")
                        </textarea>
                        <input type="hidden" id="hfDisputeReplacementItems" value="@(dispute.DisputeReplacementItems + Environment.NewLine + orderItem.ProductSubOptions)" />
                    </div>
                    <div class="span2">
                        <input type="checkbox" style="float: left; margin-right: 7px;" name="IsFulDisputeReplacementItems" value="True" @read @(dispute.IsFulDisputeReplacementItems == true ? "checked=checked" : "") 
                            id="IsFulDisputeReplacementItems" />
                        Full Item
                    </div>
                </div>
                <div class="row-fluid" style="margin-bottom: 10px">
                    <div class="span2"></div>
                    <div class="span6">
                        <input type="checkbox" style="float: left; margin-right: 7px;" value="True" name="Urgent" @(dispute.Urgent == true ? "checked=checked" : "") />
                        Mark as Urgent
                    </div>
                    <div class="span4">
                        <a href="@urlQuestion" class="btn btn-primary">View Questionnaire</a>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Full Description</div>
                    <div class="span10">
                        <textarea class="input-block-level" rows="3" name="Description" @read>@dispute.Description</textarea>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Signature</div>
                    <div class="span10">
                        @Html.DropDownList("SignatureID", null, "Please Select a Singature", new { @class = "input-block-level", required = "required", disabled })
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Packaging</div>
                    <div class="span10">
                        @Html.DropDownList("PackagingID", null, "Please Select a Packaging Description", new { @class = "input-block-level", required = "required", disabled })
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Consignment No.</div>
                    <div class="span10">
                        <input type="text" class="input-block-level" name="ConsignmentNumber" value="@dispute.ConsignmentNumber" @read />
                    </div>
                </div>
            </fieldset>

            <div class="span6">
                <ul class="tabs tabs-inline tabs-top orderdetail-task-tabs">
                    <li class="active">
                        <a href="#Photos" data-toggle="tab">Photos</a>
                    </li>
                    <li>
                        <a href="#Evidence" data-toggle="tab">Other Evidence</a>
                    </li>
                    <li>
                        <a href="#ItemPart" data-toggle="tab" onclick="RdmOrderItemPartDetail(@Model.OrderItemID,@Model.DisputeID,$('#ItemPart'))">Order Item Part</a>
                    </li>
                </ul>

                <div class="tab-content padding tab-content-inline tab-content-bottom orderdetail-task-tabs-content">
                    <div class="tab-pane active" id="Photos">
                        <div class="rdm-tab-scroll" style="height: 306px">
                            <div class="tbl-photodispute">
                                @Html.Action("PhotosDispute", new { disputeid = Model.DisputeID })
                            </div>
                        </div>
                        <p class="text-right"><a href="#addPhoto" role="button" data-toggle="modal" class="btn btn-primary">Add photo</a></p>
                    </div>
                    <div class="tab-pane" id="Evidence">
                        <div class="rdm-tab-scroll" style="height: 306px">
                            <div class="tbl-documentdispute">
                                @Html.Action("DocumentDispute", new { disputeid = Model.DisputeID })
                            </div>
                        </div>
                        <p class="text-right"><a href="#addDocument" role="button" data-toggle="modal" class="btn btn-primary">Add document</a></p>
                    </div>
                    <div class="tab-pane" id="ItemPart"></div>
                </div>

                <div class="border-padding10 text-right">
                    <div class="row-fluid">
                        <div class="span3"></div>
                        <div class="span4">Preferred Collection Date</div>
                        <div class="span4">
                            <div id="datetimepicker2" class="input-append">
                                <input data-format="dd/MM/yyyy HH:mm:ss" type="text" name="PreferredCollectionDate" value="@string.Format("{0:dd/MM/yyyy HH:mm:ss}", dispute.PreferredCollectionDate)" />
                                <span class="add-on">
                                    <i data-time-icon="icon-time" data-date-icon="icon-calendar" class="icon-calendar"></i>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span2"></div>
                        <div class="span4">
                            Collection Fee Required
                            <input type="checkbox" style="float: right; margin-left: 10px;" value="True" name="CollectionFeeRequired" @(dispute.CollectionFeeRequired == true ? "checked=checked" : "") />
                        </div>
                        <div class="span3">Collection Fee(£)</div>
                        <div class="span3">
                            <input type="text" class="input-block-level" name="CollectionFee" value="@string.Format("{0:0.00}", dispute.CollectionFee)"  />
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="border-padding10" style="margin: 0">
            <div class="row-fluid">
                <div class="span5">
                    @if (dispute.ActionID > 0)
                    {
                        <div style="font-weight: bold; color: red">NOTE: You cannot edit this RDM becuase it has already been Approved or Rejected.  You can still edit the RDM photos.</div>
                    }
                </div>
                <div class="span7 text-right">
                    <button class="btn btn-primary" style="margin-right: 10px" onclick="javascript:window.close();">Cancel</button>
                    @*<button class="btn btn-primary" style="margin-right: 10px" type="button" id="saverdm">Save</button>*@
                    <button class="btn btn-primary" type="button" id="sendapproval" @(dispute.ActionID > 0 ? "disabled=disabled" : "")>Send for Approval</button>
                </div>
            </div>
        </div>
    </form>
    <div class="row-fluid" style="margin-top: 15px">
        <div class="span3">RDM Added By: <strong>@Model.AddedBy</strong></div>
        <div class="span3">Date: <strong>@Model.DatePlaced</strong></div>
        <div class="span3">Approved By: <strong>@Model.ApprovedByKRM</strong></div>
        <div class="span3">Date: <strong>@Model.ApprovedOn</strong></div>
    </div>
    <div class="row-fluid">
        <fieldset class="span6">
            <legend>Collections</legend>
            <div class="row-fluid">
                <div class="span2">Collection Items</div>
                <div class="span10">
                    <textarea class="input-block-level" rows="3" disabled="disabled">@dispute.ApprovedCollectionItems</textarea>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">Collection Date</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.ScheduledCollectionDate" />
                </div>
                <div class="span2">Courier</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.carrierName" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">No. Parcels</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.NumberOfParcels" />
                </div>
                <div class="span2">Collection No</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.CourierCollectionNumber" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">Arranged By</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.CollectionArrangedBy" />
                </div>
            </div>
        </fieldset>

        <fieldset class="span6">
            <legend>Replacements</legend>
            <div class="row-fluid">
                <div class="span2">Replacement Items</div>
                <div class="span10">
                    <textarea class="input-block-level" rows="3" disabled="disabled">@Model.ApprovedReplacementItems</textarea>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">Replacement Date</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.ReplacementDate" />
                </div>
                <div class="span2">Courier</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.ReplacementCourier" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">No. Parcels</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.ReplacementParcels" />
                </div>
                <div class="span2">Further Details</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.ReplacementDetails" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">Arranged By</div>
                <div class="span4">
                    <input type="text" class="input-block-level" disabled="disabled" value="@Model.ReplacementArrangedBy" />
                </div>
            </div>
        </fieldset>
    </div>
</div>
